<?php

namespace App\Http\Logic;

use App\Models\AdminUser;

class User extends Logic
{
    // 获取用户列表
    public function search($params = []): array
    {
        $data = ['list' => []];
        $query = AdminUser::query()
            ->select(['id', 'nickname', 'created_time']);
        $data['total'] = $query->count();
        if ($data['total'] === 0) {
            return $data;
        }
        $query->orderByDesc('id')->offset(($params['page'] - 1) * $params['size'])->limit($params['size']);
        $list = $query->get()->toArray();
        $data['list'] = $list;
        return $data;
    }
}
